import pyautogui
import time
import pygetwindow as gw

# 等待游戏加载完毕
time.sleep(3)

# 获取所有窗口
windows = gw.getAllWindows()

# 找到当前活动窗口
for window in windows:
    if window.isActive:
        print(f"当前活动窗口的标题是: {window.title}")
        break

pyautogui.keyDown('esc')  # 按下Esc键
time.sleep(0.5)
pyautogui.keyUp('esc')    # 松开Esc键
time.sleep(0.2)
print('开始战斗')


pyautogui.keyDown('right')
pyautogui.keyUp('right')
time.sleep(0.3)
pyautogui.keyDown('enter')
pyautogui.keyUp('enter')
time.sleep(0.3)
pyautogui.keyDown('enter')
pyautogui.keyUp('enter')
time.sleep(0.3)

pyautogui.press('right')  # 按下向右键
time.sleep(0.2)
pyautogui.press('enter')  # 按下回车键
time.sleep(0.2)
pyautogui.press('enter')  # 按下回车键
time.sleep(0.5)

pyautogui.press('right')  # 按下向右键
time.sleep(0.2)
pyautogui.press('enter')  # 按下回车键
time.sleep(0.2)
pyautogui.press('enter')  # 按下回车键
time.sleep(0.5)